package com.zyz.base.response;

import com.google.common.collect.Lists;
import com.zyz.base.request.PageCondition;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author wangjinliang
 */
public class PageMessage<T> extends Message<T> {
    @Setter
    @Getter
    @ApiModelProperty("页数据")
    private List<T> records;

    @Setter
    @Getter
    @ApiModelProperty("总条数")
    private long total;

    @Setter
    @Getter
    @ApiModelProperty("页大小")
    private int pageSize;

    @Setter
    @Getter
    @ApiModelProperty("当前页")
    private int pageNum;

    public PageMessage(PageCondition pageCondition) {
        super();
        this.pageNum = pageCondition.getPageNum();
        this.pageSize = pageCondition.getPageSize();
        this.total = 0;
        this.records = Lists.newArrayList();
    }

    public PageMessage(int code, String message, PageCondition pageCondition) {
        super(code, message);
        this.pageNum = pageCondition.getPageNum();
        this.pageSize = pageCondition.getPageSize();
        this.total = 0;
        this.records = Lists.newArrayList();
    }

    public PageMessage(PageCondition pageCondition, long total, List<T> records) {
        super();
        this.pageNum = pageCondition.getPageNum();
        this.pageSize = pageCondition.getPageSize();
        this.total = total;
        this.records = records;
    }
}